package dao;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;

import form.ConnectionDB;

import model.Danhgia;

public class DanhgiaDAO {

	public static boolean insert(Danhgia danhgia)
			throws ClassNotFoundException, SQLException {
		Connection connection = ConnectionDB.getConnection();
		String sql = "insert into danhgia(hinh,title,title_khongdau,mucdanhgia_id,ngayviet,thoigianviet,uudiem,nhuocdiem,noidung) values (?,?,?,?,?,?,?,?,?)";
		PreparedStatement ps = connection.prepareStatement(sql);
		ps.setString(1, danhgia.getHinh());
		ps.setString(2, danhgia.getTitle());
		ps.setString(3, danhgia.getTitle_khongdau());
		ps.setInt(4, danhgia.getMucdanhgia().getMucdanhgia_id());
		ps.setDate(5, danhgia.getNgayviet());
		ps.setTime(6, danhgia.getThoigianviet());
		ps.setString(7, danhgia.getUudiem());
		ps.setString(8, danhgia.getNhuocdiem());
		ps.setString(9, danhgia.getNoidung());

		int change = 0;
		change = ps.executeUpdate();
		connection.close();
		if (change > 0) {
			return true;
		} else {

			return false;
		}

	}

	public static void main(String[] args) {

	}

}
